package com.ruoyi.wx.controller;

import java.util.List;

import com.ruoyi.wx.domain.Goods;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wx.domain.Ordersdetail;
import com.ruoyi.wx.service.IOrdersdetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单详情Controller
 *
 * @author hxie
 * @date 2020-12-24
 */
@RestController
@RequestMapping("/wx/ordersdetail")
public class OrdersdetailController extends BaseController
{
    @Autowired
    private IOrdersdetailService ordersdetailService;

    /**
     * 查询订单详情列表
     */
//    @PreAuthorize("@ss.hasPermi('wx:ordersdetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(Ordersdetail ordersdetail)
    {
        startPage();
        List<Ordersdetail> list = ordersdetailService.selectOrdersdetailList(ordersdetail);
        return getDataTable(list);
    }

    /**
     * 导出订单详情列表
     */
    @PreAuthorize("@ss.hasPermi('wx:ordersdetail:export')")
    @Log(title = "订单详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Ordersdetail ordersdetail)
    {
        List<Ordersdetail> list = ordersdetailService.selectOrdersdetailList(ordersdetail);
        ExcelUtil<Ordersdetail> util = new ExcelUtil<Ordersdetail>(Ordersdetail.class);
        return util.exportExcel(list, "ordersdetail");
    }

    /**
     * 获取订单详情详细信息
     */
//    @PreAuthorize("@ss.hasPermi('wx:ordersdetail:query')")
    @GetMapping(value = "/{detailid}")
    public AjaxResult getInfo(@PathVariable("detailid") String detailid)
    {
        return AjaxResult.success(ordersdetailService.selectOrdersdetailById(detailid));
    }

    /**
     * 新增订单详情
     */
//    @PreAuthorize("@ss.hasPermi('wx:ordersdetail:add')")
    @Log(title = "订单详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Ordersdetail ordersdetail)
    {
        return toAjax(ordersdetailService.insertOrdersdetail(ordersdetail));
    }

    /**
     * 修改订单详情
     */
//    @PreAuthorize("@ss.hasPermi('wx:ordersdetail:edit')")
    @Log(title = "订单详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Ordersdetail ordersdetail)
    {
        return toAjax(ordersdetailService.updateOrdersdetail(ordersdetail));
    }

    /**
     * 删除订单详情
     */
//    @PreAuthorize("@ss.hasPermi('wx:ordersdetail:remove')")
    @Log(title = "订单详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailids}")
    public AjaxResult remove(@PathVariable String[] detailids)
    {
        return toAjax(ordersdetailService.deleteOrdersdetailByIds(detailids));
    }

    /**
     * 根据ordersId查询
     * @param ordersId
     * @return
     */
    @RequestMapping("/selectByordersId")
    public List<Ordersdetail> selectByordersId(String ordersId){
        List<Ordersdetail> list=ordersdetailService.selectByordersId(ordersId);
        return list;
    }
}
